package com.yunji.base.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.yunji.base.domain.BelongDO;
import com.yunji.base.params.BelongSearchParam;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Package com.yunji.user.mapper
 * FileName:	BelongMapper.java
 * Copyright:	Copyright © 2024 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-08-15 17:58:06.922
 * Description:
 * 所属信息数据交互
 * Modification History:
 * Author					Date						Version			Description
 * --------------------------------------------------------------------------------
 * HuaAo				2024-08-15 17:58:06			1.0				1.0 Version
 */
public interface IBelongMapper extends MPJBaseMapper<BelongDO> {
    @Select({"<script> SELECT DISTINCT ${searchField} FROM v3_belong b LEFT JOIN sys_user usr ON b.user_id = usr.user_id WHERE  b.del_flag = 0",
            " <if test='belongId != null'> AND b.belong_id = #{belongId}</if>",
            " <if test='parentId != null'> AND b.parent_id = #{parentId}</if>",
            " <if test='belongName != null'> AND b.belong_name LIKE CONCAT('%',#{belongName},'%')</if>",
            " <if test='phoneNumber != null'>AND usr.user_name LIKE CONCAT('%',#{phoneNumber},'%')</if> </script>"})
    List<String> searchTableField(BelongSearchParam param);
}
